package com.ws.universal.tools.wsui.headle;

import android.content.res.ColorStateList;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ImageView;

import androidx.core.widget.CompoundButtonCompat;
import androidx.core.widget.ImageViewCompat;

import com.ws.universal.tools.wsui.help.QMUISkinHelper;

import org.jetbrains.annotations.NotNull;

public class QMUISkinRuleTintColorHandler extends QMUISkinRuleColorStateListHandler {
    @Override
    protected void handle(@NotNull View view, @NotNull String name, ColorStateList colorStateList) {
        if (colorStateList == null) {
            return;
        }
        if (view instanceof ImageView) {
            ImageViewCompat.setImageTintList((ImageView) view, colorStateList);
        } else if (view instanceof CompoundButton) {
            CompoundButtonCompat.setButtonTintList((CompoundButton) view, colorStateList);
        } else {
            QMUISkinHelper.warnRuleNotSupport(view, name);
        }
    }
}
